package com.jvxb.manage.livable.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jvxb.common.constants.DbConstants;
import com.jvxb.common.utils.CommonUtil;
import com.jvxb.manage.livable.entity.AssetsCluster;
import com.jvxb.manage.livable.mapper.AssetsClusterMapper;
import com.jvxb.manage.livable.service.AssetsClusterService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author jvxb
 * @since 2022-01-05
 */
@Service
public class AssetsClusterServiceImpl extends ServiceImpl<AssetsClusterMapper, AssetsCluster> implements AssetsClusterService {

    @Override
    public IPage<AssetsCluster> selectPages(String name, String dbType, Integer current, Integer size) {
        IPage<AssetsCluster> assetsClusterIPage = baseMapper.selectPages(new Page<>(current, size), name, dbType);
        return assetsClusterIPage;
    }

    @Override
    public List<Map> getClusterMenu(Long clusterId, String dbType) {
        List<Map> menuList = new ArrayList<>();
        menuList.add(CommonUtil.getMap("label", "集群详情", "name", "clusterDetail"));
        menuList.add(CommonUtil.getMap("label", "数据查询", "name", "dataQuery"));
        menuList.add(CommonUtil.getMap("label", "数据变更", "name", "dataAlter"));
        menuList.add(CommonUtil.getMap("label", "实例管理", "name", "instanceCtl"));
        if (dbType.equalsIgnoreCase(DbConstants.MYSQL)) {
            menuList.add(CommonUtil.getMap("label", "账户管理", "name", "dbAccount"));
        }
        menuList.add(CommonUtil.getMap("label", "集群监控", "name", "clusterMonitor"));
        menuList.add(CommonUtil.getMap("label", "服务变更", "name", "dbChange"));
        menuList.add(CommonUtil.getMap("label", "日志中心", "name", "dbLog"));
        return menuList;
    }
}
